package zom.zenjava.zendeploy.gui.jfx;

import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import zom.zenjava.zendeploy.model.ApplicationProfile;

public class ApplicationProfileView extends GridPane
{
    private Label nameLabel;
    private Label versionLabel;
    private Label jreVersionLabel;

    public ApplicationProfileView()
    {
        buildView();
    }

    public void setApplicationProfile(ApplicationProfile appProfile)
    {
        if (appProfile != null)
        {
            nameLabel.setText(appProfile.getName());    
            versionLabel.setText(appProfile.getVersion());
            jreVersionLabel.setText(appProfile.getJreReference().getVersion());
        }
        else
        {
            nameLabel.setText(null);
            versionLabel.setText(null);
            jreVersionLabel.setText(null);
        }
    }
    
    private void buildView()
    {
        getStyleClass().add("application-profile-view");
        setHgap(10);
        setVgap(6);

        int row = 0;

        add(new Label("Name:"), 0, row);
        nameLabel = new Label();
        add(nameLabel, 1, row++);

        add(new Label("Version:"), 0, row);
        versionLabel = new Label();
        add(versionLabel, 1, row++);

        add(new Label("Java Version:"), 0, row);
        jreVersionLabel = new Label();
        add(jreVersionLabel, 1, row);
    }
}
